<template>
	<view class="content">
		<view class="msg-head">
			<view class="msg-head-tit">全部消息</view>
			<image src="../../static/msg-right.png"></image>
		</view>
		<view class="msg-item" v-for="item,i in list" :key="i">
			<view class="msg-item-box" @click="lianXi(item.c_user_id)">
				<image src="../../static/logo.png"></image>
				<view class="msg-item-box-right">
					<view class="msg-item-top">
						<view class="msg-item-name">{{ item.link_position }}</view>
						<view class="msg-item-date">{{ item.created_at}}</view>
					</view>
					<view class="msg-item-cont">{{ item.content }}</view>
				</view>
			</view>
			<view class="bot-line"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				list:[]
			}
		},
		onLoad() {
			this.getData()
			this.authLogin()
		},
		onShow() {
			this.authLogin()
		},
		methods: {
			async getData() {
				const res = await this.get('/Index/User/get_recent_message_user');
				if(res.code == 200){
					this.list = res.data
				}
			},
			lianXi(id){
				uni.navigateTo({
					url:'./msg_lianxi?user_id2='+id
				})
			},
			authLogin(){
				uni.getStorage({
				    key: 'auth',
				    success: (e) => {
						console.log("auth-success:",e)
				    },
					fail: () => {
						uni.navigateTo({
							url:'../login/login'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		.msg-head{
			display: flex;
			.msg-head-tit{
				font-size: 32upx;
				font-weight: bold;
				margin: 44upx 4upx 36upx 30upx;
			}
			image{
				width: 36upx;
				height: 36upx;
				margin-top: 48upx;
			}
		}
		.msg-item{
			.msg-item-box{
				display: flex;
				image{
					width: 92upx;
					height: 92upx;
					border-radius: 50%;
					margin: 0 20upx 0 30upx;
				}
				.msg-item-box-right{
					.msg-item-top{
						width: 575upx;
						display: flex;
						justify-content: space-between;
						.msg-item-name{
							font-size: 30upx;
							font-weight: bold;
						}
						.msg-item-date{
							color: #A6A6A6;
							font-size: 26upx;
						}
					}
					.msg-item-cont{
						color: #666666;
						font-size: 26upx;
						margin-top: 10upx;
					}
				}
			}
			.bot-line{
				width: 576upx;
				margin: 38upx 0 40upx 142upx;
				border: 2upx solid #EEEEEE;
			}
		}
	}
</style>
